/**
 * @param {string} s
 * @return {number}
 */
export var lengthOfLastWord = function (s) {
  s = s.trim()
  for (var i = s.length - 1; i >= 0; i--) {
    if (s[i] === ' ') {
      return s.length - i - 1
    }
  }
  return s.length
}

/**
 * @param {string} s
 * @return {number}
 */
export var lengthOfLastWord2 = function (s) {
  const sArr = s.trim().split(' ')
  return sArr[sArr.length - 1].length
}
